<?php

	//校验密码接口-check_password.php
	//http://42.121.57.193:7788/platform/check_password.php?phone=18665986379&password=123456

	include_once "init.php";

	$phone 		= $_GET["phone"];
	$password		= $_GET["password"];

	if(''==$phone)
	{
		die("-1|电话号码不可以为空");
	}
	if(''==$password)
	{
		die("-1|密码不可以为空");
	}
	if (strlen($phone) != 11 || false==is_numeric($phone) || ord($phone)!=49)
	{
		die("-1|手机号码必须是11位数字，并且以1开头");
	}
	if (strlen($password) < 6 || strlen($password) > 16)
	{
		die("-1|密码格式不正确");
	}

	$con    = db_connect(DB_NAME);
	//先获取配置信息，查看号码是否存在
	$res = mysql_query("SELECT phone FROM user where phone='$phone'") or die("-1|查询数据库失败");
	$row = mysql_fetch_row($res);

	if (empty($row))
	{
		mysql_close($con);
		die("-1|手机号码未注册");
	}

	$res2 = mysql_query("SELECT phone FROM user where phone='$phone' and password='$password'") or die("-1|查询数据库失败");
	$row2 = mysql_fetch_row($res2);
	mysql_close($con);
	if (empty($row2))
	{
		
		die("-1|密码不正确");
	}
	else
	{
		echo '0|';
	}
?>